const STATE = {
	count: 0,
};

export default {
	namespace: "counter", // Model 的命名空间
	state: STATE,
	reducers: {
		increment(state: typeof STATE) {
			return { ...state, count: state.count + 1 }; // 增加计数
		},
		decrement(state: typeof STATE) {
			return { ...state, count: state.count - 1 }; // 减少计数
		},
	},
	effects: {
		*incrementAsync(_: any, { call, put }: any) {
			yield call(() => new Promise(resolve => setTimeout(resolve, 1000))); // 模拟异步
			yield put({ type: "increment" }); // 调用 increment reducer
		},
	},
};
